home *** CD-ROM | disk | FTP | other *** search
/ Super PC 34 / Super PC 34 (Shareware).iso / spc / UTIL / DJGPP2 / V2 / DJTST200.ZIP / tests / libclink / compare.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-26  |  1.2 KB  |  73 lines

  1. /*
  2. **  Usage: compare oldlib.armap newlib.armap
  3. */
  4.  
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include <stdlib.h>
  8.  
  9. #include "slist.h"
  10.  
  11. void
  12. loadsyms(char *fn, StringList &sl)
  13. {
  14.   FILE *f;
  15.   char line[1000];
  16.   char sym[1000];
  17.   f = fopen(fn, "r");
  18.   if (f == 0)
  19.   {
  20.     perror(fn);
  21.     exit(1);
  22.   }
  23.   fgets(line, 1000, f);
  24.   fgets(line, 1000, f);
  25.   while (fgets(line, 1000, f))
  26.   {
  27.     if (line[0] <= ' ')
  28.       break;
  29.     sscanf(line, "%s", sym);
  30.     sl.add(sym);
  31.   }
  32.   fclose(f);
  33.   sl.sort();
  34. }
  35.  
  36. int
  37. main(int argc, char **argv)
  38. {
  39.   StringList old_objs;
  40.   StringList new_objs;
  41.   int i, col=80, need_banner=1;
  42.  
  43.   loadsyms(argv[1], old_objs);
  44.   loadsyms(argv[2], new_objs);
  45.  
  46.   for (i=0; i<old_objs.count; i++)
  47.   {
  48.     char *s = old_objs[i];
  49.     if (s[0] != '_')
  50.       continue;
  51.     if (!new_objs.has(s))
  52.     {
  53.       if (need_banner)
  54.       {
  55.     need_banner = 0;
  56.     printf("Symbols in old library, but not in new one:");
  57.       }
  58.       col += strlen(s) + 1;
  59.       if (col > 77)
  60.       {
  61.     col = strlen(s)-1;
  62.     putchar('\n');
  63.       }
  64.       else
  65.     fputs("  ", stdout);
  66.       fputs(s+1, stdout);
  67.     }
  68.   }
  69.   if (!need_banner)
  70.     putchar('\n');
  71.   return 0;
  72. }
  73.